package util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2017/12/14.
 */
public class MapUtil {


    public static List valueGetKey(Object value, Map map) {
        List arr = new ArrayList();
        Set<Map.Entry> set = map.entrySet();
        for (Map.Entry s : set) {
            if (value == null) {
                if (s.getValue() == null) {
                    arr.add(s.getKey());
                }
            } else {
                if (value.equals(s.getValue())) {
                    arr.add(s.getKey());
                }
            }
        }
        return arr;
    }

    public static Object valueGetFirstKey(Object value, Map map) {

        List list = valueGetKey(value, map);

        if (list.isEmpty()) {
            return null;
        } else {
            return list.get(0);
        }

    }


}
